package edu.zcmu.seckill.controller;

import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.utils.CaptchaUtil;
import edu.zcmu.seckill.response.R;
import edu.zcmu.seckill.service.VerifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;

@Slf4j
@RestController
public class VerifyController {

    @Autowired
    VerifyService verifyService;

    @RequestMapping("/captcha")
    public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {
        verifyService.captcha(request,response);
    }

    @RequestMapping("/checkCaptcha")
    public R checkCaptcha(@RequestParam("code") String code,HttpServletRequest request){
        R result =verifyService.checkCaptcha(code,request);
        return result;
    }

}
